﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using JM.JCY.Common;
using NCS.IConnect.PolicyInjection.CallHandlers;
using JM.JCY.BusinessComponent;
using JM.JCY.BusinessEntity;
using JM.JCY.DataAccess;
namespace JM.JCY.BusinessFacade
{
   public class NewsfeedBF:JCYBusinessFacadeBase<NewsfeedBC>,INewsfeed
    {
       public NewsfeedBF()
           : base(new NewsfeedBC())
       {
       }

       public NewsfeedDataSet.T_FeedPostDataTable GetFeedPost(string appType, int appId, string excludePostId)
       {
           return this.BusinessComponent.GetFeedPost(appType, appId, excludePostId);
       }

       public NewsfeedDataSet.T_FeedPostDataTable GetMoreFeedPost(string appType, int appId, string excludePostId)
       {
           return this.BusinessComponent.GetMoreFeedPost(appType, appId, excludePostId);
       }

       public void InsertFeedPost(NewsfeedDataSet ds)
       {
           using (JCYTransaction t = NewTransaction())
           {
               try
               {
                   this.BusinessComponent.InsertFeedPost(ds);
                   t.Commit();
               }
               catch (Exception ex)
               {
                   t.Dispose();
                   throw ex;
               }
           } 
       }

       public NewsfeedDataSet.T_FeedPostDataTable GetFeedPostEntity(int feedPostId)
       {
           return this.BusinessComponent.GetFeedPostEntity(feedPostId);
       }

       public NewsfeedDataSet.T_FeedPostDataTable GetFeedPostByObjectId(int objId)
       {
           return this.BusinessComponent.GetFeedPostByObjectId(objId);
       }

       public NewsfeedDataSet.T_FeedCommentDataTable InsertComment(NewsfeedDataSet ds)
       {
           using (JCYTransaction t = NewTransaction())
           {
               try
               {
                   NewsfeedDataSet.T_FeedCommentDataTable dt = this.BusinessComponent.InsertComment(ds);
                   t.Commit();
                   return dt;
               }
               catch (Exception ex)
               {
                   t.Dispose();
                   throw ex;
               }
           } 
       }

       public NewsfeedDataSet.T_FeedCommentDataTable GetFeedCommentByNewsfeedId(int newsfeedId)
       {
           return this.BusinessComponent.GetFeedCommentByNewsfeedId(newsfeedId);
       }

       public NewsfeedDataSet.T_FeedCommentDataTable GetFeedCommentEntity(int commentId)
       {
           return this.BusinessComponent.GetFeedCommentEntity(commentId);
       }

       public NewsfeedDataSet.T_FeedCommentDataTable GetMoreCommentsByObj(int objId, int dataNum)
       {
           return this.BusinessComponent.GetMoreCommentsByObj(objId, dataNum);
       }

       public bool DeletePostCommentById(int commentId)
       {
           return this.BusinessComponent.DeletePostCommentById(commentId);
       }

       public DateTime GetFeedPostLastestUpdateTime(int feedPostId)
       {
           return this.BusinessComponent.GetFeedPostLastestUpdateTime(feedPostId);
       }

       public NewsfeedDataSet.T_FeedCommentDataTable GetPostCommentByPostId(int feedpostId, int dataNum)
       {
           return this.BusinessComponent.GetPostCommentByPostId(feedpostId, dataNum);
       }

       public void DeleteFeedPost(int feedpostId)
       {
           this.BusinessComponent.DeleteFeedPost(feedpostId);
       }

       public DateTime GetLatestFeedPostUpdateTime(string appType, int appId)
       {
           return this.BusinessComponent.GetLatestFeedPostUpdateTime(appType, appId);
       }

       public NewsfeedDataSet.T_UserInfoDataTable GetUserInfoEntity(int userId)
       {
           return this.BusinessComponent.GetUserInfoEntity(userId);
       }
    }
}
